home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / CPX / GENERAL.TC / GENERAL.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  19.2 KB  |  800 lines

  1. /* GENERAL.C 
  2.  *==========================================================================
  3.  * DATE:    February 2, 1990
  4.  * DESCRIPTION: GENERAL CPX Dialog Box
  5.  */
  6.  
  7.  
  8.  
  9. /* INCLUDE FILES
  10.  *==========================================================================
  11.  */ 
  12. #include <sys\gemskel.h>
  13. #include <tos.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16.  
  17. #include "country.h"
  18.  
  19. #include "general.h"
  20. #include "general.rsh"
  21.  
  22. #include "..\cpxdata.h"
  23.  
  24. #include "super.h"
  25. #include "status.h"
  26. #include "ttblit.h"
  27. #include "dclick.h"
  28. #include "keybell.h"
  29. #include "keyboard.h"
  30. #include "block2.h"
  31.  
  32.  
  33. /* DEFINES
  34.  *==========================================================================
  35.  */
  36. #define UP     0                /* wait button up   */
  37. #define DOWN     1                /* wait button down */
  38.  
  39.  
  40. typedef struct _gen
  41. {
  42.    int     keyclick;    /* Keyclick   On/Off               */
  43.    int  bell;        /* Bell          On/Off               */
  44.    int  dclick;        /* Double click rate: 0, 1, 2, 3, 4 */
  45.    
  46.    int  repeat;        /* Keyboard repeat rate            */
  47.    int  response;    /* Keyboard response rate        */
  48.    
  49.    int  BlitCache;    /* Blitter/TT Cache On/Off        */
  50.    
  51.    int  TT_Speaker;    /* TT Speaker On/Off  */
  52.    int  STE_Chip;    /* STE Chip speed - 8mhz, 16mhz no cache
  53.                 *                  16 mhz with cache
  54.                 */
  55.                 
  56. }GEN;
  57.  
  58.  
  59.  
  60.  
  61. /* PROTOTYPES
  62.  *==========================================================================
  63.  */
  64.  
  65. BOOLEAN  cdecl cpx_call( GRECT *rect );
  66. BOOLEAN     cdecl cpx_call( GRECT *rect );
  67.  
  68. int   handle_button( int button, WORD *msg );
  69. void  Set_Data( void );
  70. void  Get_Data( void );
  71. void  Set_Objects( void);
  72. void  Redraw_Objects( void );
  73.  
  74. void  pop_data( void );
  75. void  push_data( void );
  76. void  wait_button( int flag );
  77. void  open_vwork( void );
  78. void  close_vwork( void );
  79. void  XDeselect( OBJECT *tree, int button );
  80. void  XSelect( OBJECT *tree, int button );
  81. void  MakeActivator( int xtree, int obj );
  82.  
  83.  
  84. /* EXTERNALS
  85.  *==========================================================================
  86.  */
  87. extern GEN save_vars;
  88.  
  89.  
  90. /* GLOBALS 
  91.  *==========================================================================
  92.  */
  93.  
  94. XCPB *xcpb;
  95. CPXINFO cpxinfo;
  96. int vhandle;
  97. int  AES_Version;
  98. int  numcol;
  99. int  hcnt=0;            /* handle count */
  100. int  currez;
  101.  
  102. /* VDI arrays */
  103. int    contrl[12], intin[128], intout[128], ptsin[128], ptsout[128],
  104.     work_in[12], work_out[57];
  105.  
  106.  
  107. GEN old_value, cur_value;
  108.  
  109. char blanks[5][30];    /* Used for Pop_Up String Manipulation  */
  110. char *blank[5];        /* and is subject to change after review*/
  111.  
  112. OBJECT *xtree;        /* This is a global tree that is passed to 
  113.              * XFORM_DO(). It is EITHER  the GENERAL tree
  114.              * or the PARTZ tree.
  115.              * When status is selected, we switch xtree ptrs
  116.              * to that xform_do will work correctly.
  117.              * When we switch back, we must restore the
  118.              * GENERAL tree pointer.
  119.              * In addition, the ObX and ObYs of the tree
  120.              * must be updated.
  121.              */
  122. MFORM    Other;        /* Mouse Buffer for using MFsave() */
  123.              
  124.  
  125. /* FUNCTIONS
  126.  *==========================================================================
  127.  */
  128.  
  129.  
  130. /* cpx_init() 
  131.  *==========================================================================
  132.  * initialize the cpx ( what else can I say? )
  133.  *
  134.  * IN:  XCPB Xcpb:    The structure passed into the cpx
  135.  * OUT: return the CPXINFO structure to XCONTROL
  136.  *
  137.  * GLOBALS:    XCPB *xcpb:    We'll be using this one for calls
  138.  *        int vhandle:    workstation handle
  139.  *        CPXINFO cpxinfo: filled with functions address...
  140.  */        
  141. CPXINFO
  142. *cdecl cpx_init( XCPB *Xcpb )
  143. {
  144.     OBJECT *tree;
  145.     int    i;
  146.  
  147.     appl_init();
  148.  
  149.     currez = Getrez();                /* find current resolution */
  150.     xcpb = Xcpb;
  151.     vhandle = xcpb->handle;
  152.     if( xcpb->booting )
  153.     {
  154.       /* Read in the default settings and set the hardware */
  155.       cur_value = save_vars;
  156.       Init_Speed();
  157.       Init_Block2();
  158.       Set_Data();
  159.       return( ( CPXINFO *)TRUE );  
  160.     }
  161.     else
  162.     {
  163.  
  164.        open_vwork();
  165.        close_vwork();
  166.        numcol = work_out[13];            /* size of CLUT */
  167.        
  168.        AES_Version = _GemParBlk.global[0];
  169.         
  170.        if( !xcpb->SkipRshFix )
  171.           (*xcpb->rsh_fix)( NUM_OBS, NUM_FRSTR, NUM_FRIMG, NUM_TREE,
  172.                            rs_object, rs_tedinfo, rs_strings, rs_iconblk,
  173.                            rs_bitblk, rs_frstr, rs_frimg, rs_trindex,
  174.                            rs_imdope );
  175.        /*
  176.         * Get the current settings of the hardware and store them
  177.         * in the current GEN structure
  178.         */
  179.        cur_value = save_vars;
  180.        Init_Speed();
  181.        Init_Block2();
  182.        Get_Data();
  183.        push_data();
  184.        cpxinfo.cpx_call   = cpx_call;
  185.        cpxinfo.cpx_draw   = NULL;
  186.        cpxinfo.cpx_wmove  = NULL;
  187.        cpxinfo.cpx_timer  = NULL;
  188.        cpxinfo.cpx_key    = NULL;
  189.        cpxinfo.cpx_button = NULL;
  190.        cpxinfo.cpx_m1       = NULL;
  191.        cpxinfo.cpx_m2      = NULL;
  192.        cpxinfo.cpx_hook      = NULL;
  193.        cpxinfo.cpx_close  = NULL;
  194.  
  195.        if( !xcpb->SkipRshFix )
  196.        {
  197.         if(( AES_Version >= 0x0330 )
  198.         && ( numcol > LWHITE ) )
  199.         {
  200.          tree = ( OBJECT *)rs_trindex[ GENERAL ];
  201.          MakeActivator( GENERAL, GSAVE );
  202.          MakeActivator( GENERAL, GOK );
  203.          MakeActivator( GENERAL, GCANCEL );
  204.      ObH( GSAVE )    = 16;
  205.      ObH( GOK )      = 16;
  206.      ObH( GCANCEL )  = 16;
  207.      ObIndex( B4 ) &= 0xff00ffffL;
  208.  
  209.      ObX( GSAVE ) += 1;
  210.      ObY( GSAVE ) += 2;
  211.      ObW( GSAVE ) -= 2;
  212.      ObH( GSAVE ) -= 3;
  213.  
  214.      ObX( GOK ) += 1;
  215.      ObY( GOK ) += 2;
  216.      ObW( GOK ) -= 2;
  217.      ObH( GOK ) -= 3;
  218.  
  219.      ObX( GCANCEL ) += 1;
  220.      ObY( GCANCEL ) += 2;
  221.      ObW( GCANCEL ) -= 2;
  222.      ObH( GCANCEL ) -= 3;
  223.  
  224.      ObX( LRESP ) += 2;
  225.      ObX( RRESP ) -= 2;
  226.      for( i = RESPBASE; i <= LRESP; i++ )
  227.      {
  228.         MakeActivator( GENERAL, i );
  229.         ObH( i ) = 16;
  230.         if( ( ObType( i ) & 0x00ff ) == G_BOXTEXT )
  231.           TedColor( i ) = ( TedColor( i ) & 0xff70 ) | LWHITE | 0x70;
  232.         
  233.         if( ( ObType( i ) & 0x00ff ) == G_BOXCHAR )
  234.           ObIndex( i ) = ( ObIndex( i ) & 0xffffff70 ) | LWHITE | 0x70;
  235.  
  236.        if( i == RESPBASE )       
  237.        {
  238.          ObX( i ) = ObX( LRESP ) + ObW( LRESP ) + 5;
  239.          ObW( i ) = ( ObX( RRESP ) - 5 ) - ObX( i );
  240.        }
  241.           
  242.      }   
  243.      ObIndex( B6 ) &= 0xff00ffffL;
  244.      ObIndex( B7 ) &= 0xffffff70L;
  245.  
  246.  
  247.      ObX( LREPEAT ) += 2;
  248.      ObX( RREPEAT ) -= 2;     
  249.      for( i = LREPEAT; i <= KREPEAT; i++ )
  250.      {
  251.         MakeActivator( GENERAL, i );
  252.         ObH( i ) = 16;
  253.         if( ( ObType( i ) & 0x00ff ) == G_BOXTEXT )
  254.           TedColor( i ) = ( TedColor( i ) & 0xff70 ) | LWHITE | 0x70;
  255.  
  256.         if( ( ObType( i ) & 0x00ff ) == G_BOXCHAR )
  257.           ObIndex( i ) = ( ObIndex( i ) & 0xffffff70 ) | LWHITE | 0x70;
  258.  
  259.         if( i == REPTBASE )       
  260.         {
  261.           ObX( i ) = ObX( LREPEAT ) + ObW( LREPEAT ) + 5;
  262.           ObW( i ) = ( ObX( RREPEAT ) - 5 ) - ObX( i );
  263.         }
  264.  
  265.      }   
  266.      ObIndex( B8 ) &= 0xff00ffffL;
  267.      ObIndex( B9 ) &= 0xffffff70L;
  268.      
  269.      ObIndex( B0 ) &= 0xffffff70L;
  270.      MakeActivator( GENERAL, STATUS );
  271.      ObX( STATUS ) += 1;
  272.      ObY( STATUS ) += 2;
  273.      ObW( STATUS ) -= 2;
  274.      ObH( STATUS ) -= 4;
  275.  
  276.  
  277.      MakeActivator( GENERAL, DOUBLE );
  278.      ObX( DOUBLE ) += 1;
  279.      ObY( DOUBLE ) += 1;
  280.      ObW( DOUBLE ) -= 2;
  281.      ObH( DOUBLE ) -= 2;
  282.          TedColor( DOUBLE ) = ( TedColor( DOUBLE ) & 0xFF70 ) | LWHITE | 0x70;
  283.      ObIndex( B5 ) &= 0xff00ff70L;          
  284.  
  285.      ObIndex( B1 ) = ( ObIndex( B1 ) & 0xffffff70L ) | LWHITE | 0x70;
  286.      ObIndex( B2 ) = ( ObIndex( B1 ) & 0xffffff70L ) | LWHITE | 0x70;
  287.      ObIndex( B3 ) &= 0xffffff70L;
  288.  
  289.          TedColor( BLK1TXT ) = ( TedColor( BLK1TXT ) & 0xFF70 );
  290.      ObIndex( BLK1 ) &= 0xffffff70L;
  291.      tree[(BLK1TXT)].ob_spec.tedinfo->te_thickness = 0;
  292.      
  293.          TedColor( BLK2TXT ) = ( TedColor( BLK2TXT ) & 0xFF70 );
  294.      ObIndex( BLK2 ) &= 0xffffff70L;
  295.      tree[(BLK2TXT)].ob_spec.tedinfo->te_thickness = 0;
  296.      
  297.          tree = ( OBJECT *)rs_trindex[ PARTZ ];
  298.          MakeActivator( PARTZ, STATOK );
  299.         }
  300.        } /*        if( !xcpb->SkipRshFix )*/
  301.  
  302.        return( &cpxinfo );
  303.     }
  304. }
  305.  
  306.  
  307.  
  308.  
  309.  
  310. /* cpx_call()
  311.  *==========================================================================
  312.  * Execute the cpx
  313.  *
  314.  * 
  315.  */
  316. BOOLEAN
  317. cdecl cpx_call( GRECT *rect )
  318. {
  319.      OBJECT *tree = ( OBJECT *)rs_trindex[ GENERAL ];
  320.      int button;
  321.      int quit = 0;
  322.      WORD msg[8];
  323.  
  324.      xtree = tree;     
  325.      ObX( ROOT ) = rect->g_x;
  326.      ObY( ROOT ) = rect->g_y;
  327.      Set_Objects();
  328.      Objc_draw( tree, ROOT, MAX_DEPTH, NULL );
  329.      do
  330.      {
  331.       button = (*xcpb->Xform_do)( xtree, 0, msg );
  332.       if( xtree == ( OBJECT *)rs_trindex[ PARTZ ] )
  333.          quit = stat_button( button, msg );
  334.       else
  335.              quit = handle_button( button, msg );
  336.              
  337.      }while(!quit );
  338.      return( FALSE );
  339.  
  340. }
  341.  
  342.  
  343.  
  344.  
  345. /* handle_button()
  346.  *==========================================================================
  347.  /* button handling using XFORM_DO
  348.  */
  349. int
  350. handle_button( int button, WORD *msg )
  351. {
  352.     OBJECT *tree  = (OBJECT *)rs_trindex[GENERAL];
  353.     int    done = FALSE;
  354.     BOOLEAN  click_flag = FALSE;
  355.     MRETS  mk;
  356.     int    ox, oy;
  357.        
  358.     if( ( button != -1 ) && ( button & 0x8000 ) )
  359.     {
  360.       click_flag = TRUE;
  361.       button &= 0x7FFF;
  362.     }
  363.  
  364.     switch( button )
  365.     {
  366.        case GSAVE:   if( (*xcpb->XGen_Alert)( SAVE_DEFAULTS ) )
  367.                     {
  368.                     (*xcpb->CPX_Save)( &cur_value, sizeof( GEN ) );
  369.                     push_data();
  370.                     Set_Data();
  371.                     }
  372.                     XDeselect( tree, GSAVE );
  373.                     break;
  374.                     
  375.        case GOK:     done = TRUE;
  376.                     Set_Data();
  377.                     Deselect( GOK );
  378.                     break;
  379.                    
  380.        case GCANCEL: done = TRUE;
  381.                     pop_data();
  382.                     Deselect( GCANCEL );
  383.                     break;
  384.        
  385.        case STATUS:  graf_mkstate( &mk.x, &mk.y, &mk.buttons, &mk.kstate );
  386.                     if( objc_find( tree, ROOT, MAX_DEPTH, mk.x, mk.y ) == STATUS )
  387.                         do_status();
  388.                     break;
  389.                     
  390.        case BELL:    keybell_handle( BELLICON, &cur_value.bell );
  391.                     break;
  392.                     
  393.        case KEYCLICK:keybell_handle( KEYICON, &cur_value.keyclick );
  394.                     break;
  395.                     
  396.        case M0:
  397.        case M1:
  398.        case M2:
  399.        case M3:
  400.        case M4:         Dclick_Select( button );
  401.                     break;
  402.                     
  403.        case DOUBLE:  Dclick_Handle( click_flag, button );
  404.                  break;
  405.  
  406.            case KREPEAT:   (*xcpb->MFsave )( MFSAVE, &Other );
  407.                    if( AES_Version >= 0x0320 )
  408.                        graf_mouse( FLAT_HAND, 0L );
  409.  
  410.  
  411.                 if(( AES_Version >= 0x0330 )
  412.                       && ( numcol > LWHITE ) )
  413.                      XSelect( tree, KREPEAT );
  414.  
  415.                 graf_mkstate( &ox, &mk.y, &mk.buttons, &mk.kstate );
  416.               do
  417.               {
  418.                     graf_mkstate( &mk.x, &mk.y, &mk.buttons, &mk.kstate );
  419.               }while( mk.buttons && ( mk.x == ox ));
  420.  
  421.             if( mk.buttons && ( mk.x != ox ))
  422.             {
  423.                       (*xcpb->Sl_dragx)( tree, REPTBASE, KREPEAT, KEYMIN,
  424.                                  KEYMAX, &cur_value.repeat,
  425.                                                  KRepeat );
  426.                               Set_Kbrate();
  427.             }
  428.             
  429.                   if(( AES_Version >= 0x0330 )
  430.                         && ( numcol > LWHITE ) )
  431.                       XDeselect( tree, KREPEAT );
  432.                            
  433.                            (*xcpb->MFsave)( MFRESTORE, &Other );
  434.                    break;
  435.                                 
  436.            case KRESPONS:  (*xcpb->MFsave)( MFSAVE, &Other );
  437.                    if( AES_Version >= 0x0320 )
  438.                        graf_mouse( FLAT_HAND, 0L );
  439.                        
  440.                 if(( AES_Version >= 0x0330 )
  441.                       && ( numcol > LWHITE ) )
  442.                      XSelect( tree, KRESPONS );
  443.  
  444.                 graf_mkstate( &ox, &mk.y, &mk.buttons, &mk.kstate );
  445.               do
  446.               {
  447.                     graf_mkstate( &mk.x, &mk.y, &mk.buttons, &mk.kstate );
  448.               }while( mk.buttons && ( mk.x == ox ));
  449.  
  450.             if( mk.buttons && ( mk.x != ox ))
  451.             {
  452.                       (*xcpb->Sl_dragx)( tree, RESPBASE, KRESPONS, KEYMIN,
  453.                                  KEYMAX, &cur_value.response,
  454.                                                  KResponse );
  455.                               Set_Kbrate();                  
  456.             }
  457.             
  458.                   if(( AES_Version >= 0x0330 )
  459.                         && ( numcol > LWHITE ) )
  460.                       XDeselect( tree, KRESPONS );
  461.  
  462.                            (*xcpb->MFsave)( MFRESTORE, &Other );
  463.                    break;
  464.                    
  465.            case RRESP:     (*xcpb->Sl_arrow)( tree, RESPBASE, KRESPONS, RRESP,
  466.                                              1, KEYMIN, KEYMAX,
  467.                                              &cur_value.response, HORIZONTAL,
  468.                                              KResponse );
  469.                            Set_Kbrate();
  470.                     break;
  471.                 
  472.            case LRESP:     (*xcpb->Sl_arrow)( tree, RESPBASE, KRESPONS, LRESP,
  473.                                              -1, KEYMIN, KEYMAX,
  474.                                              &cur_value.response, HORIZONTAL,
  475.                                              KResponse );
  476.                            Set_Kbrate();
  477.                    break;
  478.                 
  479.            case RREPEAT:   (*xcpb->Sl_arrow)( tree, REPTBASE, KREPEAT, RREPEAT,
  480.                                              1, KEYMIN, KEYMAX,
  481.                                              &cur_value.repeat, HORIZONTAL,
  482.                                              KRepeat );
  483.                            Set_Kbrate();
  484.                    break;
  485.                 
  486.            case LREPEAT:   (*xcpb->Sl_arrow)( tree, REPTBASE, KREPEAT, LREPEAT,
  487.                                              -1, KEYMIN, KEYMAX,
  488.                                              &cur_value.repeat, HORIZONTAL,
  489.                                              KRepeat );
  490.                            Set_Kbrate();
  491.                    break;
  492.  
  493.     case REPTBASE:  Graf_mkstate( &mk );
  494.             objc_offset( tree, KREPEAT, &ox, &oy );
  495.             oy = (( mk.x < ox ) ? ( -3 ) : ( 3 ) );
  496.                    (*xcpb->Sl_arrow)( tree, REPTBASE, KREPEAT, -1,
  497.                                      oy, KEYMIN, KEYMAX,
  498.                                      &cur_value.repeat, HORIZONTAL,
  499.                                      KRepeat );
  500.                    Set_Kbrate();
  501.               break;
  502.             
  503.     case RESPBASE:  Graf_mkstate( &mk );
  504.             objc_offset( tree, KRESPONS, &ox, &oy );
  505.             oy = (( mk.x < ox ) ? ( -3 ) : ( 3 ));
  506.                    (*xcpb->Sl_arrow)( tree, RESPBASE, KRESPONS, -1,
  507.                                      oy, KEYMIN, KEYMAX,
  508.                                      &cur_value.response, HORIZONTAL,
  509.                                      KResponse );
  510.                    Set_Kbrate();
  511.             break;
  512.             
  513.  
  514.     case BLK1BUTT:  Do_Speed();
  515.             break;
  516.             
  517.     case BLK2BUTT:  Do_Block2();
  518.                 
  519.     default:    if( button == -1 )
  520.               {
  521.                     switch( msg[0] )
  522.                     {
  523.                       case WM_REDRAW: Redraw_Objects();
  524.                                    break;
  525.                                    
  526.                       case AC_CLOSE:  done = TRUE;
  527.                                    pop_data();    
  528.                                    break;
  529.                                    
  530.                       case WM_CLOSED: done = TRUE;
  531.                                    Set_Data();
  532.                          break;
  533.                       default:
  534.                               break;
  535.                     }
  536.                  }
  537.                  break;
  538.     }
  539.     return( done );
  540. }
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550. /* Set_Data()
  551.  *==========================================================================
  552.  * Set keyclick, bell, double-click speed, keyboard response and repeat
  553.  * and blitter/ttcache.
  554.  */
  555. void
  556. Set_Data()
  557. {
  558.    Set_Keybell();
  559.    Set_Dclick();
  560.    Set_Kbrate();
  561.    Set_Speed();
  562.    Set_Block2();
  563. }
  564.  
  565.  
  566.  
  567. /* Get_Data()
  568.  *==========================================================================
  569.  * Get the current hardware values and shove them into the data structure
  570.  */
  571. void
  572. Get_Data( void )
  573. {
  574.     Get_Keybell();
  575.     Get_Dclick();
  576.     Get_Kbrate();
  577.     Get_Speed();
  578.     Get_Block2();
  579. }
  580.  
  581.  
  582. void
  583. Set_Objects( void)
  584. {
  585.    Keybell_Update();
  586.    Dclick_Update();
  587.    Kbrate_Update();
  588.    Speed_Update();
  589.    Block2_Update();
  590. }
  591.  
  592.  
  593.  
  594.  
  595. /*--------------------------------------------------------------------------
  596.  * OTHER Routines
  597.  *--------------------------------------------------------------------------
  598.  */
  599.  
  600.  
  601.  
  602. void
  603. push_data( void )
  604. {
  605.     old_value = cur_value;
  606. }
  607.  
  608.  
  609.  
  610. void
  611. pop_data( void )
  612. {
  613.     cur_value = old_value;
  614.     Set_Data();
  615. }
  616.  
  617.  
  618.  
  619. /* wait_button()
  620.  *==========================================================================
  621.  */
  622. void
  623. wait_button( int flag )
  624. {
  625.   MRETS m;
  626.   
  627.   Evnt_button( 1, 1, flag, &m );
  628. }
  629.  
  630.  
  631.  
  632.  
  633. /* Pop_Handle()
  634.  *==========================================================================
  635.  * Setup strings for popup menu and execute...
  636.  */
  637. int
  638. Pop_Handle( int button, char *items[], int num_items, int *default_item,
  639.             int font_size, int width )
  640. {
  641.    GRECT butn, world;
  642.    
  643.    int  i;
  644.    int  obj;
  645.    long max = 0L;
  646.    OBJECT *tree = (OBJECT *)rs_trindex[ GENERAL ];
  647.    int small = FALSE;
  648.      
  649.    butn = ObRect( button );
  650.    objc_offset( tree, button, &butn.g_x, &butn.g_y );
  651.    world = ObRect( ROOT );
  652.    objc_offset( tree, ROOT, &world.g_x, &world.g_y ); 
  653.    
  654.    
  655.    for( i = 0; i < num_items; i++ )
  656.    {
  657.        if( strlen( items[i] ) > max )
  658.                 max = strlen( items[i] );
  659.    }
  660.    if( max <= 3L )
  661.        small = TRUE;
  662.               
  663.    for( i = 0; i < num_items; i++ )
  664.    {
  665.       if( small )
  666.         strcpy( &blanks[i][0], "   " );
  667.       else
  668.         strcpy( &blanks[i][0], "  ");        /* get 2 blank spaces */
  669.       strcat( &blanks[i][0], items[ i ]);    /* copy the string    */
  670.       do
  671.       {
  672.          strcat( &blanks[i][0], " ");
  673.       }while( strlen( &blanks[i][0] ) < width );
  674.       blank[i] = &blanks[i][0];
  675.    }
  676.    
  677.    obj = (*xcpb->Popup)( blank, num_items, *default_item, font_size,
  678.                         &butn, &world );
  679.  
  680.    if( obj != -1 )
  681.           *default_item = obj;
  682.    return( obj );
  683. }
  684.  
  685.  
  686.  
  687.  
  688. void
  689. Redraw_Objects( void )
  690. {
  691.    Kbell_Redraw();
  692.    Dclick_Redraw();
  693.    Kbrate_Redraw();
  694.    Speed_Redraw();
  695.    Block2_Redraw();
  696. }
  697.  
  698.  
  699.  
  700. void
  701. do_redraw( OBJECT *tree, int obj )
  702. {
  703.    GRECT *xrect;
  704.    GRECT rect;
  705.    GRECT t;
  706.    
  707.    t = ObRect( obj );
  708.    objc_offset( tree, obj, &t.g_x, &t.g_y );   
  709.    
  710.    xrect = (*xcpb->GetFirstRect)( &t );
  711.    while( xrect )
  712.    {
  713.         rect = *xrect;
  714.         Objc_draw( tree, obj, MAX_DEPTH, &rect );
  715.         xrect = (*xcpb->GetNextRect)();
  716.    };   
  717. }
  718.  
  719.  
  720.  
  721. /*
  722.  * Open virtual workstation
  723.  */
  724. void
  725. open_vwork(void)
  726. {
  727.   int i;
  728.   
  729.   if (hcnt == 0) {
  730.       for (i = 1; i < 10;)
  731.         work_in[i++] = 1;
  732.       work_in[0] = currez + 2;
  733.       work_in[10] = 2;
  734.       vhandle = xcpb->handle;
  735.       v_opnvwk(work_in, &vhandle, work_out);
  736.   }
  737.   hcnt++;
  738. }
  739.  
  740.  
  741. /*
  742.  * Close virtual workstation
  743.  */
  744. void
  745. close_vwork(void)
  746. {
  747.     hcnt--;
  748.     if( !hcnt )
  749.     {
  750.      v_clsvwk(vhandle);
  751.     vhandle = -1;
  752.     }
  753. }
  754.  
  755.  
  756.  
  757. void
  758. XDeselect( OBJECT *tree, int button )
  759. {
  760.    GRECT rect;
  761.  
  762.    Deselect( button );
  763.    rect = ObRect( button );
  764.    objc_offset( tree, button, &rect.g_x, &rect.g_y );
  765.    rect.g_x -= 2;
  766.    rect.g_y -= 2;
  767.    rect.g_w += 4;
  768.    rect.g_h += 4;
  769.    Objc_draw( tree, button, MAX_DEPTH, &rect );
  770. }
  771.  
  772.  
  773. void
  774. XSelect( OBJECT *tree, int button )
  775. {
  776.    GRECT rect;
  777.  
  778.    Select( button );
  779.    rect = ObRect( button );
  780.    objc_offset( tree, button, &rect.g_x, &rect.g_y );
  781.    rect.g_x -= 2;
  782.    rect.g_y -= 2;
  783.    rect.g_w += 4;
  784.    rect.g_h += 4;
  785.    Objc_draw( tree, button, MAX_DEPTH, &rect );
  786. }
  787.  
  788.  
  789.  
  790. void
  791. MakeActivator( int xtree, int obj )
  792. {
  793.    OBJECT *tree;
  794.    
  795.    tree = ( OBJECT *)rs_trindex[ xtree ];
  796.    
  797.    ObFlags( obj ) |= IS3DOBJ;
  798.    ObFlags( obj ) |= IS3DACT;
  799. }
  800.